﻿Public Class register
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Dim Svc As New IsisAssoWebServices.WebServicesClient

        'Response.Write(Svc.UserAccountCreate("Monsieur", "Pascal", "TRAN", "neoconception2@msn.com", "toto"))
        'Response.Write(Svc.UserAccountList(My.Settings.pvkey).Length)
        'Response.Write(Svc.UserAccountDelete(2))

    End Sub
    
    Protected Sub ButtonSubmit_Click(sender As Object, e As EventArgs) Handles ButtonSubmit.Click
        Dim svc As New IsisAssoWebServices.WebServicesClient
        Dim ReturnData As Long = svc.UserAccountCreate(My.Settings.pvkey, user_civilite.SelectedValue, user_prenom.Text, user_nom.Text, user_email.Text, user_password.Text)
        PanelFormCreate.Visible = False
        PanelErrorCreateAccount.Visible = False
        PanelFormConfirm.Visible = False
        Select Case ReturnData
            '0 : no init
            '-1 : account with this email exist
            '-2 : error processing creation
            'else : account ok with ID returning

            Case 0
                MsgError.Text = "Erreur du Serveur (000), veuillez recommencer"
                PanelErrorCreateAccount.Visible = True
            Case -1
                MsgError.Text = "Cette adresse Email existe déjà, identifiez vous avec votre mot de passe, ou recommencer avec une autre adresse email."
                PanelErrorCreateAccount.Visible = True
            Case -2
                MsgError.Text = "Erreur du Serveur (002), veuillez recommencer"
                PanelErrorCreateAccount.Visible = True
            Case Else
                PanelFormConfirm.Visible = True
                Session.Contents("logged") = "yes"
                Session.Contents("logged_name") = user_prenom.Text & " " & user_nom.Text
                Session.Contents("id_user") = ReturnData
        End Select

    End Sub

    Protected Sub ButtonTryAgain_Click(sender As Object, e As EventArgs) Handles ButtonTryAgain.Click
        PanelFormCreate.Visible = True
        PanelErrorCreateAccount.Visible = False
        PanelFormConfirm.Visible = False
    End Sub
End Class